/* 接口中使用【可索引属性】 */
interface IPerson {
   name: string;
   age: number;

   /* 人还有狠多其它特性，一言难尽 */
   // 任意多个【字符串：any】类型的key-value
   [key: string]: any;
}

let p: IPerson = {
   name: "张三疯",
   age: 60,

   // 随意扩展任意多个其它属性
   skill: "太极拳",
   money: 1234567890,
};

type Formatter = (row: any, column: any, cellValue: any, index: number) => any;

/* 定义专门用于存储Formatter的Map */
interface FormatterMap {
   [key: string]: Formatter;
}

const formatters = {
   actors: (row: any, column: any, cellValue: any, index: number) => {
      return (
         row.actors
            .slice(0, 3)
            .map(a => a.name)
            .join(",") + "等"
      );
   },
   premierAt: (row: any, column: any, cellValue: any, index: number) => {
      return new Date(row.premierAt * 1000).toLocaleDateString();
   },
};
